package com.ilink.ilinkcommon.utils;

/**
 * <h3>new-ilink-java-backend</h3>
 *
 * @author LiuZheng
 * @description <p>封装ThreadLocal，保存当前登录用户信息</p>
 * @date 2024-09-16 10:06
 **/
public class UserContext {
    private static final ThreadLocal<String> tl = new ThreadLocal<>();

    /**
     * @Author LiuZheng
     * @Description 存储当前登录用户ID
     * @Date 10:08 2024-09-16
     * @Param [userId]
     * @return void
     **/
    public static void setUserId(String userId) {
        tl.set(userId);
    }

    public static String getUserId() {
        return tl.get();
    }

    public static void removeUserId() {
        tl.remove();
    }

}
